class MyPage extends BaseList {
    constructor(orderby, flag, productId, $pagesize, $pagination, listUrl, onLineEditUrl, checkBoxName) {
        super(orderby, flag, $pagesize, $pagination, listUrl, onLineEditUrl, checkBoxName);
        this.productId = productId;
    }
    GetFilter(pageIndex) {
        let item = super.GetFilter(pageIndex);
        item['ProductId'] = parseInt(this.productId);

        return JSON.stringify(item);
    }
    FetchAll() {
        this.FetchForPage(1);
    }
    EmptyTableContent() {
        $("#tabData01 tbody").empty();
    }
    SetTableContent(result) {
        $("#tabData01 tbody").empty();
        let content_01 = '';
        this.rows = result.length;  // 设置表格中checkbox的数量为表格的行数
        this.numCheckbox = result.length;  // 设置表格中checkbox的数量为表格的行数
        for (let i = 0; i < result.length; i++) {
            content_01 += '<tr _mash_sizeid="' + result[i].sizeid + '">';
            content_01 += '<td style="padding-left:9px;"><label class="btn" for="R-' + result[i].sizeid + '"><input id="R-' + result[i].sizeid + '" name="_select_row" type="radio" onclick="_Instance.OnChoice($(this));" value="' + result[i].sizeid + '"/><i></i><span></span></label></td>';
            content_01 += '<td>' + result[i].sizename + '</td>';
            content_01 += '</tr>';

            $("#tabData01 tbody").append(content_01);
            content_01 = '';
        }
        setOneTableRowColor("tabData01");
        this.AdjustDataTableHeight();

        $(window).resize();                     // 防止因为出现滚动条而造成画面显示问题
        $('#loading').hide();
    }
    // 选择后执行的动作
    SetChoiceData($self) {
        // 设置选择结果
        let $row = $self.parent().parent().parent();
        let _productSizeId = $self.val();                               // 成品尺码标识
        let _productSizeName = $.trim($row.find('td').eq(1).text());    // 成品尺码名
        // 返回选择结果
        return new Array(_productSizeId, _productSizeName);
    }
    SortTable(orderBy) {
        this.orderby = orderBy;
        // 得到排序数据
        this.FetchForPage(1);
    }
    AdjustDataTableHeight() {
        let h = $(window).height();
        let _rc = Math.floor((h - 70) / 25);
        let _dh = _rc * 25;
        let _tah = this.rows * 25;
        _dh = (_tah >= _dh) ? _dh : _tah;

        $("#divD1").css({"max-height": _dh, height: _dh});
    }
}

let _Instance = null;

//-----------------------------------------------------------------------------
// 页面初始化
//-----------------------------------------------------------------------------
function onPageReady() {
    let productId = jQuery.url.param("productId") === undefined ? 0 : jQuery.url.param("productId");
    _Instance = new MyPage(null, 0, productId, null, null,
            "/trade/production_instruction/lines/fetchProductSizeByProductId.html",
            null,
            "_select_row");

    _Instance.OnPageLoad();
}

// 画面大小或者位置移动
function onPageResize() {
    if (_Instance !== null)
        _Instance.AdjustDataTableHeight();
}